<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateCommoditiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commodities', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('brand_id')->comment('商品品牌=brands.id');
            $table->integer('commodity_type')->comment('商品类型=commodity_types.id');
            $table->string('commodity_code')->default('')->comment('商品编号');
            $table->string('commodity_name')->default('')->comment('商品名称');
            $table->string('commodity_desc')->default('')->comment('商品描述');
            $table->string('pictures')->comment('商品图片/json格式');
            $table->string('pick_num')->default('')->comment('商品拣货码');
            // $table->string('bar_code')->comment('商品条形码');
            $table->decimal('price', '10', '2')->default(0)->comment('市场价');
            $table->decimal('power_price', '10', '2')->default(0)->comment('消耗算力');
            // $table->string('attr')->comment('商品属性/json格式');           
            $table->tinyInteger('shelves')->default(1)->comment('上架状态 0:未上架 1:已上架');
            $table->integer('sort')->default(0)->comment('商品排序');
            $table->integer('is_deleted')->default(0)->comment('是否删除0正常1已删除');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `commodities` comment '商品表';");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commodities');
    }
}
